package com.niiwoo.civet.trade.dto;

import com.niiwoo.civet.trade.dao.entity.ProjectPackage;
import lombok.Data;


/**
 * 标的包发布排序
 */
@Data
public class ProjectPackagePublishingDTO extends ProjectPackage implements Comparable<ProjectPackagePublishingDTO> {

    /**
     * 有优先发布时间以优先发布排序，否则以预计发布时间排序
     *
     * @param o
     * @return
     */
    @Override
    public int compareTo(ProjectPackagePublishingDTO o) {
        if (this.getFirstPublishTimeMillisecond() != null && o.getFirstPublishTimeMillisecond() == null) {
            return -1;
        } else if (this.getFirstPublishTimeMillisecond() == null && o.getFirstPublishTimeMillisecond() != null) {
            return 1;
        } else if (this.getFirstPublishTimeMillisecond() != null && o.getFirstPublishTimeMillisecond() != null) {
            return o.getFirstPublishTimeMillisecond().compareTo(this.getFirstPublishTimeMillisecond());
        } else {
            return this.getExpectPublishTimeMillisecond().compareTo(o.getExpectPublishTimeMillisecond());
        }
    }
}
